<?php
/*
 * @Author: your name
 * @Date: 2020-12-23 12:01:16
 * @LastEditTime: 2020-12-25 14:45:28
 * @LastEditors: Please set LastEditors
 * @Description: 防火墙配置
 * @FilePath: /special/application/api/controller/directive/netfilter/ConfigController.php
 */

namespace app\api\controller\directive\netfilter;


use app\api\controller\BaseController;
use app\api\model\HostLearnConfigModel;
use app\common\exception\CustomException;
use think\Db;

class ConfigController extends BaseController
{
    /**
     * 防火墙配置
    */
    public function firewallConfig(){

        $data = file_get_contents('php://input','r');

        $logPath = '../runtime/API';
        if(!file_exists($logPath)){
            mkdir($logPath,0777, true);
        }

        file_put_contents('../runtime/API/防火墙配置.log', $data);

        $data = json_decode($data, true);
        $params = ['hostkey', 'hostid'];

        foreach ($params as $v){
            if(!isset($data[$v])){
                throw new CustomException($v.'为必须参数', 202);
            }
        }

        //查询主机信息
        $model = new HostLearnConfigModel();
        $data = $model->firewallConfig($data['hostkey']);
        $this->setCallBackStatus(false);

        return $this->jsonOutPut($data);
    }

}